package com.wecan.micro.config;

import com.wecan.micro.feign.FeignErrorDecoder;
import com.wecan.micro.feign.FeignRequestInterceptor;
import feign.RequestInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.annotation.PostConstruct;

/**
 * @Author liuzhihao
 * @Date 2022.01.16
 * @Version ${version}
 * @Description ${description}
 */
@Configuration
@Slf4j
public class FeignConfig {

    @PostConstruct
    public void postConstruct() {
        log.info("[APP] |- feign远程调用服务初始化");
    }

    @Bean
    public FeignErrorDecoder feignErrorDecoder() {
        log.info("[APP] |- feign调用服务异常统一处理拦截器初始化");
        return new FeignErrorDecoder();
    }

    @Bean
    public RequestInterceptor requestInterceptor() {
        log.info("[APP] |- 初始化feign调用请求头请求体处理");
        return new FeignRequestInterceptor();
    }
}
